<template>
  <div>
    <a-card :bordered="false">
      <a-steps :current="current">
        <a-step size="small" v-for="item in steps" :key="item.title" :title="item.title" />
      </a-steps>
    </a-card>
    <a-card :bordered="false" style='margin-top: 5px'>
      <step1 v-show='current===0'  ref='step1'></step1>
      <step2 v-show='current===1' :startDate='startDate' :endDate='endDate' ref='step2'></step2>
      <step3 v-show='current===2' :startDate='startDate' :endDate='endDate' ref='step3'></step3>
      <step4 v-show='current===3' :startDate='startDate' :endDate='endDate' ref='step4'></step4>

      <div style='margin-top: 10px;text-align: center;'>
        <a-button style='margin-right: 10px' type='primary' @click='previous' v-show='current>0'>上一步</a-button>
        <a-button style='margin-left: 10px' type='primary' @click='next' v-show='current<3'>下一步</a-button>
        <a-button style='margin-left: 10px' type='primary' @click='finish' v-show='current===3'>完成</a-button>
      </div>
    </a-card>
  </div>
</template>

<script>


import Step1 from '@views/epa/epa-statistics/Step/Step1'
import Step2 from '@views/epa/epa-statistics/Step/Step2'
import Step3 from '@views/epa/epa-statistics/Step/Step3'
import Step4 from '@views/epa/epa-statistics/Step/Step4'
import EpaSortService from '@/myService/EpaSortService'
export default {
  name: 'EpaStatisticsAdd',
  components:{
    Step1,
    Step2,
    Step3,
    Step4
  },
  data(){
    return{
      current: 0,
      steps: [{title: '展示数据'},{title: '模板统计'},{title: '污染小类展示'},{title: '统计汇总'},],
      startDate:'',
      endDate:'',
      id:'',
    }
  },
  created() {
    this.getDate()
  },
  methods:{
    getDate(){
      EpaSortService.getStartDate().then((res)=>{
        console.log(res)
        this.startDate=res.result.startDate;
        this.endDate=res.result.endDate;
        this.id=res.result.id;
      })
    },
    next(){
      if(this.current===0){
        this.$refs.step2.getSortPolluteQx()
      }
      if(this.current===1){
        console.log("2")
        this.$refs.step3.getCategoryStatisticsAll()
      }
      if(this.current===2){
        this.$refs.step4.getDataSourceList()
        // EpaSortService.updateSortWeek({id:this.id}).then((res)=>{
        //   console.log(res)
        // })
      }
      this.current++;
    },

    previous() {
      this.current--;
    },
    finish(){
      EpaSortService.updateSortWeek({id:this.id}).then((res)=>{
        console.log(res)
      })
      this.$router.push('/epa/epa-statistics-home')
    }
  }
}
</script>

<style scoped>

</style>
